local skel = fk.CreateSkill {
  name = "role_exmode_mingtu__lb_feng",
}

Fk:loadTranslationTable{
  ["role_exmode_mingtu__lb_feng"] = "丰",
  --[":role_exmode_mingtu__lb_feng"] = "每轮结束时，你可以令体力值唯一最小的角色回复1点体力。",
  --[":role_exmode_mingtu__lb_feng"] = "每轮结束时，你可以令一名体力值最小的角色回复1点体力。",
  [":role_exmode_mingtu__lb_feng"] = "每轮结束时，你可以令一名体力值唯一最小或为1的角色回复1点体力。",
  ["#role_exmode_mingtu__lb_feng"] = "丰：你可以令 %dest 回复1点体力",
  ["#role_exmode_mingtu__lb_feng_ask"] = "丰：你可以令一名体力值唯一最小或为1的角色回复1点体力",
}

skel:addEffect(fk.RoundEnd, {
  can_trigger = function (self, event, target, player, data)
    local room = player.room
    if player:hasSkill(skel.name) then
      local recover = table.find(room.alive_players, function (to)
        return to:isWounded() and (not table.find(room:getOtherPlayers(to), function (t)
          return t.hp <= to.hp
        end) or to.hp == 1)
      end)
      if recover and recover:isWounded() then
        --event:setCostData(self, {tos = {recover}})
        return true
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local tos = table.filter(room.alive_players, function (to)
        return to:isWounded() and (not table.find(room:getOtherPlayers(to), function (t)
          return t.hp <= to.hp
        end) or to.hp == 1)
      end)
    if #tos == 0 then return end
    if #tos > 1 then
      tos = room:askToChoosePlayers(player, {
        targets = tos,
        min_num = 1,
        max_num = 1,
        skill_name = skel.name,
        cancelable = true,
        prompt = "#role_exmode_mingtu__lb_feng_ask"
      })
      event:setCostData(self, {tos = tos})
      return #tos > 0
    else
      event:setCostData(self, {tos = tos})
      return player.room:askToSkillInvoke(player, {skill_name = skel.name, prompt = "#role_exmode_mingtu__lb_feng::"..tos[1].id})
    end
    --return player.room:askToSkillInvoke(player, {skill_name = skel.name, prompt = "#role_exmode_mingtu__lb_feng::"..event:getCostData(self).tos[1].id})
  end,
  on_use = function (self, event, target, player, data)
    player.room:recover{
      who = event:getCostData(self).tos[1],
      num = 1,
      skillName = skel.name,
      recoverBy = player,
    }
  end,
})

return skel
